﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeBehind="BillOnline.aspx.cs" Inherits="UdrinkWater_Project.Officer.BillOnline" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <dx:ASPxRoundPanel ID="pnBill" runat="server" HeaderText="ใบเสร็จ" Width="100%">
        <HeaderStyle Font-Size="Large" />
        <PanelCollection>
            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                
                <asp:Panel ID="Panel1" runat="server">
                    <fieldset><legend>รายการสั่งซื้อ</legend>
                    <table style="width: 100%">
                        <tr>
                            <td width="10%">
                                &nbsp;</td>
                            <td style="width: 25%; height: 32px;" width="40%">
                                &nbsp;</td>
                            <td width="10%">
                                &nbsp;</td>
                            <td style="width: 25%; height: 32px;" align="right">
                                <dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxButton1_Click" 
                                    Text="พิมพ์ใบเสร็จ">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                        <tr>
                            <td width="10%">
                                <dx:ASPxLabel ID="ASPxLabel4" runat="server" Text="วันที่">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%; height: 32px;" width="40%">
                                <dx:ASPxTextBox ID="txtDate" runat="server" BackColor="#D3E4A6" ReadOnly="True" 
                                    Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td width="10%">
                                <dx:ASPxLabel runat="server" Text="วันที่ส่ง" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%; height: 32px;">
                                <dx:ASPxTextBox ID="txtShipp" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;">
                                <dx:ASPxLabel runat="server" Text="รหัสพนักงาน" Width="100px" ID="ASPxLabel7">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtEmpname" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%">
                                <dx:ASPxLabel ID="ASPxLabel8" runat="server" 
                                    Text="ชื่อพนักงาน" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtEmpn" runat="server" BackColor="#D3E4A6" ReadOnly="True" 
                                    Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel5" runat="server" Text="รหัสลูกค้า" Width="100px" 
                                    style="margin-bottom: 0px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtCustomer" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel3" runat="server" Text="ชื่อลูกค้า" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%" width="50%" valign="middle">
                                <dx:ASPxTextBox ID="txtCustomerName" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel6" runat="server" Text="ที่อยู่จัดส่ง" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtAddress" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel9" runat="server" Text="ตำบล" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%" valign="middle" width="50%">
                                <dx:ASPxTextBox ID="txtDistric" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel10" runat="server" Text="อำเภอ" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtAmphur" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel11" runat="server" Text="จังหวัด" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%" valign="middle" width="50%">
                                <dx:ASPxTextBox ID="txtProvince" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel12" runat="server" Text="รหัสไปรษณีย์" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtZipcode" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%" width="50%">
                                &nbsp;</td>
                            <td style="width: 25%" valign="middle" width="50%">
                                &nbsp;</td>
                        </tr>
                    </table>
                     </fieldset>
                </asp:Panel>
               
                <asp:Panel ID="Panel2" runat="server">
                    <fieldset>
                        <legend>รายละเอียดการสั่งซื้อ</legend>
                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="SqlDataSource1" Width="100%" 
                            OnSummaryDisplayText="ASPxGridView1_SummaryDisplayText">
                        <TotalSummary>
                            <dx:ASPxSummaryItem DisplayFormat="รวม {0:#,###.00}" FieldName="Total" 
                                ShowInColumn="Total" ShowInGroupFooterColumn="Total" SummaryType="Sum" />
                        </TotalSummary>
                        <Columns>
                            <dx:GridViewDataTextColumn FieldName="Total" ShowInCustomizationForm="True" 
                                VisibleIndex="14" Caption="รวม">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn Caption="รายการ" FieldName="Number" 
                                                ShowInCustomizationForm="True" UnboundType="String" VisibleIndex="0">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                                <DataItemTemplate>
                                                    <%#Container.ItemIndex +1 %>
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataDateColumn FieldName="Order_Date" 
                                ShowInCustomizationForm="True" VisibleIndex="0" Visible="False">
                            </dx:GridViewDataDateColumn>
                            <dx:GridViewDataTextColumn FieldName="Customer_ID" 
                                ShowInCustomizationForm="True" VisibleIndex="1" Visible="False">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="CusName" ReadOnly="True" 
                                ShowInCustomizationForm="True" VisibleIndex="2" Visible="False">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataDateColumn FieldName="Shipped_date" 
                                ShowInCustomizationForm="True" VisibleIndex="3" Visible="False">
                            </dx:GridViewDataDateColumn>
                            <dx:GridViewDataTextColumn FieldName="Delivery_Address" ShowInCustomizationForm="True" 
                                VisibleIndex="4" Visible="False">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Status" ShowInCustomizationForm="True" 
                                VisibleIndex="5" Visible="False">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Product_ID" 
                                ShowInCustomizationForm="True" VisibleIndex="6" Caption="รหัสสินค้า">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Product_name" 
                                ShowInCustomizationForm="True" VisibleIndex="9" Caption="ชื่อสินค้า">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Product_Count" 
                                ShowInCustomizationForm="True" VisibleIndex="11" Caption="จำนวน">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Unit_Name" ShowInCustomizationForm="True" 
                                VisibleIndex="10" Caption="หน่วย">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Price" ShowInCustomizationForm="True" 
                                VisibleIndex="12" Caption="ราคา/หน่วย">
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="Discount" ShowInCustomizationForm="True" 
                                VisibleIndex="13" Caption="ส่วนลด">
                            </dx:GridViewDataTextColumn>
                        </Columns>
                        <SettingsPager Mode="ShowAllRecords">
                        </SettingsPager>
                        <Settings ShowFooter="True" />
                    </dx:ASPxGridView>
                    </fieldset>
                </asp:Panel>
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        onselecting="SqlDataSource1_Selecting" 
        
        
        
        SelectCommand="SELECT TB_Order.Order_Date, TB_Employee.ID_Card AS EmpID, TB_Order.Customer_ID, TB_Customer.Prefix + ' ' + TB_Customer.Firstname + ' ' + TB_Customer.Lastname AS CusName, TB_Order.Shipped_date, TB_Order.Delivery_Address, TB_Order.Status, TB_Order.Employee_ID, TB_Employee.Prefix + ' ' + TB_Employee.Firstname + ' ' + TB_Employee.Lastname AS EmpName, TB_Orderlist.Product_ID, TB_Product.Product_name, TB_Orderlist.Product_Count, TB_Unit_Category.Unit_Name, TB_Orderlist.Price, TB_Orderlist.Discount, TB_Orderlist.Product_Count * TB_Orderlist.Price - TB_Orderlist.Discount AS Total, TB_District.DISTRICT_NAME, TB_Province.PROVINCE_NAME, TB_Aumphur.AMPHUR_NAME, TB_Order.Zipcode FROM TB_Order INNER JOIN TB_District ON TB_Order.District_ID = TB_District.DISTRICT_ID LEFT OUTER JOIN TB_Aumphur ON TB_Order.Aumphur_ID = TB_Aumphur.AMPHUR_ID LEFT OUTER JOIN TB_Province ON TB_Order.Province_ID = TB_Province.PROVINCE_ID LEFT OUTER JOIN TB_Customer ON TB_Order.Customer_ID = TB_Customer.ID_Card LEFT OUTER JOIN TB_Employee ON TB_Order.Employee_ID = TB_Employee.ID_Card LEFT OUTER JOIN TB_Orderlist ON TB_Order.Order_Date = TB_Orderlist.Order_Date LEFT OUTER JOIN TB_Product ON TB_Orderlist.Product_ID = TB_Product.Product_ID LEFT OUTER JOIN TB_Unit_Category ON TB_Product.Unit = TB_Unit_Category.Unit_ID WHERE (TB_Order.Order_Date = @Order_Date)">
        <SelectParameters>
            <asp:SessionParameter Name="Order_Date" SessionField="Order_Date" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
